package com.xinchao.core;

import com.xinchao.core.constant.RequestConstant;
import com.xinchao.model.User;

import javax.servlet.http.HttpServletRequest;


public class BaseController {
	
	public User getSessionUser(HttpServletRequest request) {
		User loginUser = (User) request.getSession().getAttribute(RequestConstant.SESSION_KEY_USER);
		return loginUser;
	}

	/**
	 * 获取当前登录用户城市
	 * @param request 请求
	 * @return 城市中文名
	 */
	protected String getCurrentCityName(HttpServletRequest request){
		User loginUser = (User) request.getSession().getAttribute(RequestConstant.SESSION_KEY_USER);
		return loginUser == null ? "" : loginUser.getCityName();
	}
}
